package com.byxy.dao;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.type.JdbcType;

import com.byxy.entity.Forum;

public interface ForumDao {
	@Select("select * from forum")
	@Results({ @Result(column = "forum_id", property = "forumId", jdbcType = JdbcType.INTEGER, id = true),
			@Result(column = "forum_name", property = "forumName", jdbcType = JdbcType.VARCHAR),
			@Result(column = "forum_status", property = "forumStatus", jdbcType = JdbcType.INTEGER) })
	List<Forum> findAll();

	@Select("select * from forum where forum_id=#{forumId}")
	@Results({ @Result(column = "forum_id", property = "forumId", jdbcType = JdbcType.INTEGER, id = true),
			@Result(column = "forum_name", property = "forumName", jdbcType = JdbcType.VARCHAR),
			@Result(column = "forum_status", property = "forumStatus", jdbcType = JdbcType.INTEGER) })
	Forum get(Integer forumId);

	@Insert("insert into forum(forum_name) values(#{forumName})")
	void add(@Param("forumName") String forumName);

	@Delete("delete from forum where forum_id=#{forumId}")
	void delete(@Param("forumId") Integer forumId);

	@Update("update forum set forum_name=#{forumName} where forum_id=#{forumId}")
	void update(@Param("forumName") Integer forumName, @Param("forumId") Integer forumId);
}
